home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun 1986 January & February
/
rerun-1986-01-02.d64
/
stack 64
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
4KB
|
126 lines
100 rem*****stack*****
110 gosub2000
120 dimg(10,4)
130 forb=1to5:forl=1to3:g(b,l)=0:nextl:nextb
140 print"how many bars do you want to move
150 [153]"(2,3,4 or 5)?
160 input x
170 d=0
180 forz=1to5:ifz=xthen300:nextz
300 poke53281,5:print"[147]
310 [153]" wait
320 print" 3 [146]
330 [153]" 5 wait
340 print" 7 [146]
350 [153]" 9 wait
360 print" 11 [146]
370 [153]"123stop
400 n=5:b=11
410 forc=xto1step-1
420 g(n,1)=b:b=b-2:n=n-1:nextc:gosub1230
430 ifx=2thenmm$="9 & 11"
440 ifx=3thenmm$="7,9 & 11"
450 ifx=4thenmm$="5,7,9 & 11"
460 ifx=5thenmm$="3,5,7,9 & 11"
470 print"[144]you will be moving bars ";mm$
480 print"":input"which bar do you want to move";b
490 ifb=3andx=<4then530
500 ifb=5andx=<3then530
510 ifb=7andx=<2then530
520 if(b-3)*(b-5)*(b-7)*(b-9)*(b-11)=0then540
530 print"you may only use ";mm$;"":print spc(10)"enter again!":goto480
540 fory=1to5:forr=1to3:ifg(y,r)=bthen560
550 nextr:nexty
560 forz=yto1step-1
570 ifg(z,r)=0then590
580 ifg(z,r)<bthen600
590 nextz:goto700
600 print"that bar is under another one. makeanother choice.":print"
610 [137]480
700 [133]"place bar on which stack";l
710 [139](l[171]1)[172](l[171]2)[172](l[171]3)[178]0[167]800
720 [153]"you must choose '1', '2' or '3'":[137]700
800 [129]y[178]1[164]5:[139]g(y,l)[179][177]0[167]830
810 [130]y
820 [137]860
830 [139]b[179]g(y,l)[167]860
840 [153]"you can't place a longer bar on top of asmaller one...try again!
850 print"":goto480
860 forw=1to5:forc=1to3:ifg(w,c)=bthen910
900 nextc:nextw
910 forv=1to5:ifg(v,l)<>0then940
920 nextv
930 v=5:goto950
940 v=v-1
950 g(v,l)=g(w,c):g(w,c)=0:gosub1230
960 d=d+1
970 fory=1to5:forr=1to2:ifg(y,r)<>0then480
980 nextr:nexty
990 ifd<>2^x-1then1500
1000 gosub3190
1200 poke53281,13:print"[147][144]try again[160]('y' or 'n')";:input a$
1210 if a$="n" then 1330
1220 ifa$="y" then 130
1230 forj=1to5:p=7:fors=1to3
1240 ifg(j,s)=0then1300
1250 printtab(p-int(g(j,s)/2));
1260 forw=1tog(j,s)
1270 print"[159] [146]";
1280 nextw
1290 goto1310
1300 printtab(p);" [146]";
1310 p=p+11
1320 nexts:print:nextj:return
1330 poke53280,4:poke53281,7:print"[147]
1340 [153]"thank you...please play again soon.":[129]t[178]1[164]3000:[130]:[153]"load
1350 end
1500 poke53280,0:poke53281,8:print"[147]
1510 [139]x[178]2[167]m$[178]"3 moves"
1520 [139]x[178]3[167]m$[178]"7 moves"
1530 [139]x[178]4[167]m$[178]"15 moves"
1540 [139]x[178]5[167]m$[178]"31 moves"
1550 [153]"it took you";d;"moves.
1560 print"it could have been done in only ";m$;"
1570 [153]"try harder next time!":[129]t[178]1[164]5000:[130]:[137]1200
2000 [151]53280,8:[151]53281,3:[153]"load
2010 print"
2020 [153]"
2030 print"
2040 [153]"
2050 print"
2060 [153]"
2070 print"
2080 [153]"
2090 print" ":print"":fort=1to1500:next
3000 print"[144]123
3010 [153]" wait
3020 print" [146]
3030 [153]" wait
3040 print"[158] [144]3[158] [146]
3050 [153]"stop stop5stop wait
3060 print" [144]7 [146]
3070 [153]" stop9 wait
3080 print" [144]11 [146]":fort=1to3000:next
3090 poke53280,7:poke53281,15:print"[147]
3100 [153]"to play this game you must transfer the":[153]
3110 [153]"bars from the leftwait stack to the rightwait":[153]
3120 [153]"stack, one bar at a time, never putting":[153]
3130 [153]"a longer bar on a smaller one.":[153]"
3140 print"press <return>[146] to continue
3150 [153]"list":[133] c
3160 [151]53280,2:[151]53281,7:[153]"loadstop
3170 print"you may choose from 2 to 5 bars":print
3180 print"when you start the game.":fort=1 to 1500:next:return
3190 poke53280,7:poke53281,14:print"[147]
3200 [153]"xxxxxxxxxxxxxxxxxxxxxx
3210 print"xxxxxxxxx
3220 [153]"xxxxxxxx
3230 print"xxxxxxxx
3240 [153]"xxxxxxxxxxxxxxxxxxxxx
3250 print"xxxxxxx
3260 [153]"xxxxxxx
3270 print"xxxxxxxx
3280 [153]"xxxxxxxxxxxxxxxxx
3290 print"you did it in the least possible
3300 [153]"number of moves!!!!!":[129]t[178]1[164]2500:[130]:[142]